home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / comm / irc / epic4-mos.lha / share / epic / script / tabkey.th < prev    next >
Text File  |  2002-09-18  |  2KB  |  88 lines

  1. #
  2. # These are my tabkey routines. Pressing the tabkey with nothing in your buffer
  3. # will cycle through people you are talking to or if you type part of a
  4. # nickname and then tab it will complete the nickname. Enjoy.
  5. #
  6. # - whitefang (thall@epicsol.org)
  7. #
  8.  
  9.  
  10. bind ^i parse_command proc.tabkey
  11.  
  12. alias proc.tabkey
  13. {
  14.         ^local text,word,comp,comm,nick,temp
  15.  
  16.         @ text = L, word = rightw(1 $text), comp = pattern($^\word* $chanusers())
  17.         unless (text)
  18.         {
  19.                 type /msg
  20.                 @ text = L
  21.         }
  22.         @ comm = word(0 $text), nick = word(1 $text)
  23.  
  24.         /* msg buffer routine */
  25.         if (comm == [/msg])
  26.         {
  27.                 if (finditem(TK $nick) >= 0)
  28.                 {
  29.                         parsekey erase_line
  30.                         @ temp = getitem(TK ${finditem(TK $nick)-1})
  31.                         xtype -l /msg ${temp?temp:getitem(TK ${numitems(TK)-1})}$chr(32)
  32.                 } {
  33.                         parsekey erase_line
  34.                         xtype -l /msg $getitem(TK ${numitems(TK)-1})$chr(32)
  35.                 }
  36.                 return
  37.         }
  38.  
  39.         /* nick completion routine */
  40.         if (!word || !numwords($comp) || right(1 $word) == [:])
  41.         {
  42.                 return
  43.         }
  44.         if (numwords($comp) > 1)
  45.         {
  46.                 xecho -b Matches:
  47.                 echo $comp
  48.                 return
  49.         }
  50.         if (numwords($text) == 1)
  51.         {
  52.                 parsekey erase_line
  53.                 xtype -l $comp:$chr(32)
  54.         } {
  55.                 pop text
  56.                 parsekey erase_line
  57.                 xtype -l $text $comp
  58.         }
  59. }
  60.  
  61. alias proc.add_tabkey (nick)
  62. {
  63.         if (nick)
  64.         {
  65.                 if (finditem(TK $nick) >= 0) {@ delitem(TK $finditem(TK $nick))}
  66.                 @ setitem(TK $numitems(TK) $nick)
  67.                 if (numitems(TK) == 10) {@ delitem(TK 0)}
  68.         }
  69. }
  70.  
  71. on #-dcc_chat -420 * proc.add_tabkey =$0
  72. on #-dcc_connect -420 "% CHAT *" proc.add_tabkey =$0
  73. on #-msg -420 * proc.add_tabkey $0
  74. on #-send_dcc_chat -420 * proc.add_tabkey =$0
  75. on #-send_msg -420 * proc.add_tabkey $0
  76.  
  77. alias m msg
  78. alias msg
  79. {
  80.         //msg $*
  81.         if (@)
  82.         {
  83.                 proc.add_tabkey $0
  84.         }
  85. }
  86.  
  87. # tjbh/2000
  88.